package cqupt.spark_log.main;

import java.io.File;
import java.io.FileFilter;

import cqupt.spark_log.contrant.Contant;
import cqupt.spark_log.fileio.FileFilterMan;
import cqupt.spark_log.info.ExcelInfo;
import cqupt.spark_log.utils.Utils;
/**
 * 统计每个工作负载的能耗和时间，并生成excel
 * @author TomWang
 *
 */
public class ExcelMain {
	public static void main(String[] args) {
		ExcelInfo excelInfo = new ExcelInfo();
		String experimentPath = Utils.getExperimentPath(Contant.BASE_PATH);
		File file = new File(experimentPath);
		FileFilter filter = new FileFilterMan();
		if (file.exists()) {
			File[] files = file.listFiles(filter);
			for (File tmpFile : files) {
				String name = tmpFile.getName();
				System.out.println(name);
				String[] names = name.split("-");
				String algorithm = names[0];
				String parallel = names[1];
				String index = names[2];
				File[] childFiles = tmpFile.listFiles();
				for (File tmpChildFile : childFiles) {
					if (tmpChildFile.isDirectory()) {
						String workLoad = tmpChildFile.getName();
						excelInfo.saveInfo(algorithm,parallel,index,workLoad,name);
					}
				}
			}
			excelInfo.writeAndclose();
		}
	}
}
